package mm.util;

import junit.framework.TestCase;

public class CacheTest extends TestCase {

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testGet() {
		System.out.println(Cache.get("storedKey", new CacheCallBack<String>(){
			public String get(){
				return new HardWorker().work("Ohhhhhhhhhhh");
			}
		}));
		System.out.println(Cache.get("storedKey", new CacheCallBack<String>(){
			public String get(){
				return new HardWorker().work("You");
			}
		}));
		System.out.println(Cache.get("storedKey", new CacheCallBack<String>(){
			public String get(){
				return new HardWorker().work("should");
			}
		}));
		System.out.println(Cache.get("storedKey", new CacheCallBack<String>(){
			public String get(){
				return new HardWorker().work("not");
			}
		}));
		System.out.println(Cache.get("storedKey", new CacheCallBack<String>(){
			public String get(){
				return new HardWorker().work("see");
			}
		}));
		System.out.println(Cache.get("storedKey", new CacheCallBack<String>(){
			public String get(){
				return new HardWorker().work("me");
			}
		}));
	}

}
class HardWorker{
	String work(String talk){
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return talk;
	}
}